// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://kpdus.tripod.com/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   MenuDTO.java

package com.hfstu.ifs.dto;

import com.google.common.collect.Lists;
import com.hfstu.framework.util.StringUtil;
import com.hfstu.ifs.model.*;
import java.io.Serializable;
import java.lang.reflect.InvocationTargetException;
import java.util.*;
import org.apache.commons.beanutils.BeanUtils;

// Referenced classes of package com.hfstu.ifs.dto:
//			MenuBindNavDTO, NodeSystemDTO

public class MenuDTO
	implements Serializable
{

	private String id;
	private Integer status;
	private Date createTime;
	private Date lastChangeTime;
	private String appId;
	private String code;
	private String name;
	private String nodeSystemId;
	private String nodeSystemName;
	private String icon;
	private String selectIcon;
	private String iconHover;
	private Integer noCache;
	private Integer hide;
	private String parentId;
	private Integer levelIndex;
	private Integer orderIndex;
	private String helpUrl;
	private String hasSplit;
	private String description;
	private String funcBindTag;
	private String funcDefId;
	private String funcDefName;
	private String url;
	private String target;
	private List menuBindNavDTOs;
	private NodeSystemDTO tree;
	private MenuDTO parent;
	private List childrens;
	private List childrenGroups;
	private String nodeType;

	public MenuDTO()
	{
		status = Integer.valueOf(0);
		menuBindNavDTOs = Lists.newArrayList();
		tree = null;
		parent = null;
		childrens = Lists.newArrayList();
		childrenGroups = Lists.newArrayList();
		nodeType = "menu";
	}

	public String getId()
	{
		return id;
	}

	public void setId(String id)
	{
		this.id = id;
	}

	public Integer getStatus()
	{
		return status;
	}

	public void setStatus(Integer status)
	{
		this.status = status;
	}

	public Date getCreateTime()
	{
		return createTime;
	}

	public void setCreateTime(Date createTime)
	{
		this.createTime = createTime;
	}

	public Date getLastChangeTime()
	{
		return lastChangeTime;
	}

	public void setLastChangeTime(Date lastChangeTime)
	{
		this.lastChangeTime = lastChangeTime;
	}

	public String getAppId()
	{
		return appId;
	}

	public void setAppId(String appId)
	{
		this.appId = appId;
	}

	public String getCode()
	{
		return code;
	}

	public void setCode(String code)
	{
		this.code = code;
	}

	public String getName()
	{
		return name;
	}

	public void setName(String name)
	{
		this.name = name;
	}

	public String getNodeSystemId()
	{
		return nodeSystemId;
	}

	public void setNodeSystemId(String nodeSystemId)
	{
		this.nodeSystemId = nodeSystemId;
	}

	public String getNodeSystemName()
	{
		return nodeSystemName;
	}

	public void setNodeSystemName(String nodeSystemName)
	{
		this.nodeSystemName = nodeSystemName;
	}

	public String getIcon()
	{
		return icon;
	}

	public void setIcon(String icon)
	{
		this.icon = icon;
	}

	public String getIconHover()
	{
		return iconHover;
	}

	public void setIconHover(String iconHover)
	{
		this.iconHover = iconHover;
	}

	public Integer getNoCache()
	{
		return noCache;
	}

	public void setNoCache(Integer noCache)
	{
		this.noCache = noCache;
	}

	public Integer getHide()
	{
		return hide;
	}

	public void setHide(Integer hide)
	{
		this.hide = hide;
	}

	public String getParentId()
	{
		return parentId;
	}

	public void setParentId(String parentId)
	{
		this.parentId = parentId;
	}

	public Integer getOrderIndex()
	{
		return orderIndex;
	}

	public void setOrderIndex(Integer orderIndex)
	{
		this.orderIndex = orderIndex;
	}

	public String getHelpUrl()
	{
		return helpUrl;
	}

	public void setHelpUrl(String helpUrl)
	{
		this.helpUrl = helpUrl;
	}

	public String getDescription()
	{
		return description;
	}

	public void setDescription(String description)
	{
		this.description = description;
	}

	public String getFuncBindTag()
	{
		return funcBindTag;
	}

	public void setFuncBindTag(String funcBindTag)
	{
		this.funcBindTag = funcBindTag;
	}

	public String getUrl()
	{
		return url;
	}

	public void setUrl(String url)
	{
		this.url = url;
	}

	public String getTarget()
	{
		return target;
	}

	public void setTarget(String target)
	{
		this.target = target;
	}

	public Integer getLevelIndex()
	{
		return levelIndex;
	}

	public void setLevelIndex(Integer levelIndex)
	{
		this.levelIndex = levelIndex;
	}

	public String getFuncDefId()
	{
		return funcDefId;
	}

	public void setFuncDefId(String funcDefId)
	{
		this.funcDefId = funcDefId;
	}

	public String getFuncDefName()
	{
		return funcDefName;
	}

	public void setFuncDefName(String funcDefName)
	{
		this.funcDefName = funcDefName;
	}

	public String getNodeType()
	{
		return nodeType;
	}

	public void setNodeType(String nodeType)
	{
		this.nodeType = nodeType;
	}

	public List getMenuBindNavDTOs()
	{
		return menuBindNavDTOs;
	}

	public void setMenuBindNavDTOs(List menuBindNavDTOs)
	{
		this.menuBindNavDTOs = menuBindNavDTOs;
	}

	public String getHasSplit()
	{
		return hasSplit;
	}

	public void setHasSplit(String hasSplit)
	{
		this.hasSplit = hasSplit;
	}

	public String getSelectIcon()
	{
		return selectIcon;
	}

	public void setSelectIcon(String selectIcon)
	{
		this.selectIcon = selectIcon;
	}

	public MenuDTO transfer(Menu menu)
	{
		try
		{
			BeanUtils.copyProperties(this, menu);
		}
		catch (IllegalAccessException e)
		{
			e.printStackTrace();
		}
		catch (InvocationTargetException e)
		{
			e.printStackTrace();
		}
		if (menu.getNodeSystem() != null)
		{
			setNodeSystemId(menu.getNodeSystem().getId());
			setNodeSystemName(menu.getNodeSystem().getName());
		}
		if (menu.getFuncDef() != null)
		{
			setFuncDefId(menu.getFuncDef().getId());
			setFuncDefName(menu.getFuncDef().getName());
		}
		if (menu.getMenuBindNavs() != null)
		{
			List menuBindNavList = menu.getMenuBindNavs();
			MenuBindNav menuBindNav;
			for (Iterator iterator = menuBindNavList.iterator(); iterator.hasNext(); menuBindNavDTOs.add((new MenuBindNavDTO()).transfer(menuBindNav)))
				menuBindNav = (MenuBindNav)iterator.next();

		}
		return this;
	}

	public MenuDTO transfer(Menu menu, Set pmsMenuBindNavIds)
	{
		try
		{
			BeanUtils.copyProperties(this, menu);
		}
		catch (IllegalAccessException e)
		{
			e.printStackTrace();
		}
		catch (InvocationTargetException e)
		{
			e.printStackTrace();
		}
		if (menu.getNodeSystem() != null)
		{
			setNodeSystemId(menu.getNodeSystem().getId());
			setNodeSystemName(menu.getNodeSystem().getName());
		}
		if (menu.getFuncDef() != null)
		{
			setFuncDefId(menu.getFuncDef().getId());
			setFuncDefName(menu.getFuncDef().getName());
		}
		if (menu.getMenuBindNavs() != null)
		{
			List menuBindNavList = menu.getMenuBindNavs();
			for (Iterator iterator = menuBindNavList.iterator(); iterator.hasNext();)
			{
				MenuBindNav menuBindNav = (MenuBindNav)iterator.next();
				if (pmsMenuBindNavIds != null && pmsMenuBindNavIds.contains(menuBindNav.getId()))
					menuBindNavDTOs.add((new MenuBindNavDTO()).transfer(menuBindNav));
			}

		}
		return this;
	}

	public MenuDTO getParent()
	{
		return parent;
	}

	public NodeSystemDTO getTree()
	{
		return tree;
	}

	public void setTree(NodeSystemDTO tree)
	{
		this.tree = tree;
	}

	public void setParent(MenuDTO parent)
	{
		this.parent = parent;
	}

	public List getChildrens()
	{
		return childrens;
	}

	public List getChildrenGroups()
	{
		return childrenGroups;
	}

	public void addChild(MenuDTO node)
	{
		childrens.add(node);
	}

	public List getAllChildrens()
	{
		if (childrenGroups.isEmpty())
		{
			for (int i = 0; i < childrens.size(); i++)
			{
				MenuDTO menuDTO = (MenuDTO)childrens.get(i);
				childrenGroups.add(menuDTO);
				childrenGroups.addAll(menuDTO.getAllChildrens());
			}

		}
		return childrenGroups;
	}

	public List getAllParents()
	{
		List results = Lists.newArrayList();
		for (MenuDTO parent = getParent(); parent != null; parent = parent.getParent())
			results.add(parent);

		return results;
	}

	public String toJson()
	{
		StringBuilder json = new StringBuilder();
		json.append("{");
		json.append("\"id\":\"").append(getId()).append("\",");
		json.append("\"code\":\"").append(getCode()).append("\",");
		json.append("\"name\":\"").append(getName()).append("\",");
		json.append("\"nodeSystemId\":\"").append(getNodeSystemId()).append("\",");
		json.append("\"nodeSystemName\":\"").append(getNodeSystemName()).append("\",");
		json.append("\"icon\":\"").append(StringUtil.clean(getIcon())).append("\",");
		json.append("\"selectIcon\":\"").append(StringUtil.clean(getSelectIcon())).append("\",");
		json.append("\"iconHover\":\"").append(StringUtil.clean(getIconHover())).append("\",");
		json.append("\"hide\":").append(getHide()).append(",");
		json.append("\"parentId\":\"").append(getParentId()).append("\",");
		json.append("\"orderIndex\":").append(getOrderIndex()).append(",");
		json.append("\"levelIndex\":").append(getLevelIndex()).append(",");
		json.append("\"hasSplit\":\"").append(StringUtil.clean(getHasSplit())).append("\",");
		json.append("\"helpUrl\":\"").append(StringUtil.clean(getHelpUrl())).append("\",");
		json.append("\"description\":\"").append(StringUtil.clean(getDescription())).append("\",");
		json.append("\"funcBindTag\":\"").append(StringUtil.clean(getFuncBindTag())).append("\",");
		json.append("\"funcDefId\":\"").append(StringUtil.clean(getFuncDefId())).append("\",");
		json.append("\"funcDefName\":\"").append(StringUtil.clean(getFuncDefName())).append("\",");
		json.append("\"url\":\"").append(StringUtil.clean(getUrl())).append("\",");
		json.append("\"target\":\"").append(StringUtil.clean(getTarget())).append("\",");
		json.append("\"nodeType\":\"").append(getNodeType()).append("\",");
		json.append("\"childrens\":[");
		MenuDTO menuDTO;
		for (Iterator iterator = childrens.iterator(); iterator.hasNext(); json.append(menuDTO.toJson()).append(","))
			menuDTO = (MenuDTO)iterator.next();

		if (json.charAt(json.length() - 1) == ',')
			json.deleteCharAt(json.length() - 1);
		json.append("],");
		json.append("\"menuBindNavs\":[");
		MenuBindNavDTO menuBindNavDTO;
		for (Iterator iterator1 = menuBindNavDTOs.iterator(); iterator1.hasNext(); json.append(menuBindNavDTO.toJson()).append(","))
			menuBindNavDTO = (MenuBindNavDTO)iterator1.next();

		if (json.charAt(json.length() - 1) == ',')
			json.deleteCharAt(json.length() - 1);
		json.append("]");
		json.append("}");
		return json.toString();
	}
}
